package leetcode.editor.cn;

public class Solution230 {

    int num = 0;// 排名
    int res = 0;// 记录结果

    public int kthSmallest(TreeNode root, int k) {
        helper(root, k);
        return res;
    }


    void helper(TreeNode root, int k){
        if (root == null) return;
        helper(root.left, k);
        num++;
        if (num==k){
            res = root.val;
            return;
        }
        helper(root.right, k);
    }
}
